<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<html>
<head>
    <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css" rel="stylesheet"/>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <title>用户列表</title>
    <style>
        body {
            background: #f8f1f4;
            font-family: 'Orbitron', sans-serif;
            color: #333;
        }
        .container {
            width: 95%;
            margin: 40px auto;
        }
        h2 {
            text-align: center;
            color: #ff6b9d;
            text-shadow: 0 0 5px #ff6b9d;
        }
        .navbar {
            background-color: #fff0f5;
            padding: 15px 30px;
            display: flex;
            justify-content: center;
            gap: 30px;
            box-shadow: 0 0 10px #ff6b9d;
        }
        .navbar a {
            color: #ff6b9d;
            text-decoration: none;
            font-size: 16px;
            letter-spacing: 1px;
        }
        .navbar a:hover {
            text-shadow: 0 0 10px #ff6b9d;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            background: #fff5f8;
            box-shadow: 0 0 15px #ff6b9d;
        }
        th, td {
            padding: 12px;
            border: 1px solid #ff6b9d;
            text-align: center;
        }
        th {
            background-color: #ffe6ee;
            color: #ff6b9d;
        }
        tr:hover {
            background-color: #fff0f5;
        }
        a {
            color: #ff6b9d;
            text-decoration: none;
        }
        a:hover {
            text-shadow: 0 0 5px #ff6b9d;
        }
        .add-btn {
            display: inline-block;
            padding: 10px 20px;
            background: transparent;
            border: 2px solid #ff6b9d;
            color: #ff6b9d;
            border-radius: 6px;
            margin-bottom: 20px;
            text-decoration: none;
        }
        .add-btn:hover {
            background: #ff6b9d;
            color: #fff;
        }
    </style>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@500&display=swap" rel="stylesheet">
</head>
<body>
<c:if test="${not empty errorMessage}">
    <script>
        Swal.fire({
            icon: 'error',
            title: '操作失败',
            text: '${errorMessage}',
            confirmButtonText: '确定'
        });
    </script>
</c:if>
<!-- 🚀 赛博朋克风导航栏 -->
<div class="navbar">
    <a href="${pageContext.request.contextPath}/goods/list">🧸 商品管理</a>
    <a href="${pageContext.request.contextPath}/category/list">📁 分类管理</a>
    <a href="${pageContext.request.contextPath}/order/list">📦 订单管理</a>
    <a href="${pageContext.request.contextPath}/user/list">👤 用户管理</a>
    <a href="${pageContext.request.contextPath}/user/logout">🚪 退出登录</a>
</div>

<div class="container">
    <h2>用户管理</h2>
    <a href="${pageContext.request.contextPath}/user/addForm" class="add-btn">➕ 添加新用户</a>
    <table>
        <tr>
            <th>ID</th>
            <th>用户名</th>
            <th>邮箱</th>
            <th>类型</th>
            <th>状态</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        <c:forEach var="user" items="${userList}">
            <tr>
                <td>${user.uid}</td>
                <td>${user.uname}</td>
                <td>${user.email}</td>
                <td>${user.type}</td>
                <td>
                    <c:choose>
                        <c:when test="${user.active == 1}">激活</c:when>
                        <c:otherwise>未激活</c:otherwise>
                    </c:choose>
                </td>
                <td>
                    <fmt:formatDate value="${user.createdAt}" pattern="yyyy-MM-dd"/>
                </td>
                <td>
                    <a href="${pageContext.request.contextPath}/user/editForm/${user.uid}">编辑</a> |
                    <a href="${pageContext.request.contextPath}/user/delete/${user.uid}" onclick="return confirm('确定删除该用户吗？');">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>

</body>
</html>